<?php
/**
 * FastApp.
 * 2/28/25
 * @Author deepsea159
 * @Contact telegram:deepsea159
 */

use Hyperf\Database\Seeders\Seeder;
use Hyperf\DbConnection\Db;

class Config extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run(): void
    {
        $this->initConfig();
    }

    public function initConfig(): void
    {
        $appid = 400001;
        $data = [
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('支持币种', $appid, 'symbol', 'BRL,TRX');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('新人体验次数', $appid, 'register_demo_num', '1000');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('代理结算周期(天)', $appid, 'agent_profit_interval', '7');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('最小充值金额', $appid, 'recharge_min_amount', '10');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('应用域名', $appid, 'app_domain', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('应用名称', $appid, 'app_name', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('应用logo', $appid, 'app_logo', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('应用tg_bot_token', $appid, 'app_tg_bot_token', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('官方群', $appid, 'app_group', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('官方搜索群', $appid, 'app_chat_search', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('客服', $appid, 'app_kf', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('团队简介', $appid, 'app_team_desc', '<a href\=\"\">承接Telegram相关系统、机器人、小程序、定制、破解、游戏、支付、棋牌、交易所等开发</a>');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('团队名称', $appid, 'app_team', '<a href=\"\">运营团队：脉搜极客团队 [MaiSoo Team] </a>');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('频道信息收录', $appid, 'app_channel_index', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('群组信息收录', $appid, 'app_group_index', '');",
            "INSERT INTO fastapp_app_setting (name, account_type, `key`, val) VALUES('选妃就选凤凰阁', $appid, 'app_hoenix', '');",
        ];
        foreach (array_merge($data, $this->dict($appid)) as $sql) {
            try {
                Db::connection('default')->insert($sql);
            } catch (\Throwable) {
            }
        }

    }

    public function dict(int $appid): array
    {
        $res = [];
        if (!Db::connection('default')->table('system_dict_data')->where(['type_id' => 122, 'code' => 'robot_service'])->exists()) $res = [
            "INSERT INTO system_dict_data (type_id, label, value, code, sort, status, created_by, updated_by, created_at, updated_at, deleted_at, remark) VALUES(122, 'TG搜索机器人', '\\App\\Hoenix\\Api\\Service\\TgSearchBotService', 'robot_service', 1, 1, 1, 1, '2025-03-08 11:27:07', '2025-03-08 11:27:07', NULL, NULL);",
            "INSERT INTO system_dict_data (type_id, label, value, code, sort, status, created_by, updated_by, created_at, updated_at, deleted_at, remark) VALUES(122, '凤凰阁客户TG机器人', '\\App\\Hoenix\\Api\\Service\\TgCustomerBotService', 'robot_service', 1, 1, 1, 1, '2025-03-01 10:21:09', '2025-03-01 10:38:03', NULL, NULL);",
            "INSERT INTO system_dict_data (type_id, label, value, code, sort, status, created_by, updated_by, created_at, updated_at, deleted_at, remark) VALUES(122, '凤凰阁妃子TG机器人', '\\App\\Hoenix\\Api\\Service\\TgConcubineBotService', 'robot_service', 1, 1, 1, 1, '2025-03-01 10:21:09', '2025-03-01 10:38:03', NULL, NULL);",
        ];
        if (!Db::connection('default')->table('system_dict_data')->where(['value' => $appid, 'code' => 'account_type'])->exists()) {
            $res[] = "INSERT INTO system_dict_data (type_id, label, value, code, sort, status, created_by, updated_by, created_at, updated_at, deleted_at, remark) VALUES(107, '凤凰阁', $appid, 'account_type', 1, 1, 1, 1, '2025-03-01 12:21:10', '2025-03-01 12:21:10', NULL, NULL);";
        }
        return $res;
    }
}